﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Collections.Specialized;
using ueEngine.Biz.Core.AppService.Recruitment;
using ueEngine.Biz.Inf.LogicEntity;
using ueEngine.Biz.Core.AppService.Member;
using ueEngine.Biz.Core.ExServer.WorkPool.WorkHandle.FullSearch;
using ueEngine.Framework.Common;
using ueEngine.Framework.Exception;
using ueEngine.Web.WebLogic.Model;
using ueEngine.Biz.Core.AppService.Support;
using ueEngine.Web.WebLogic;
using ueEngine.Web.WebLogic.PageDataProxy;
using ueEngine.Biz.Core.ExServer.WorkPool;
using ueEngine.Biz.Core.ExServer.WorkPool.WorkHandle.Email;
using ueEngine.Biz.Core.AppService.NewBiz;
using System.Net;
using System.Threading;

namespace ueEngine.Web.Controllers
{
    //[TraceBehavior]
    [ErrorHandle]
    [Compress]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            //

            var proxydata = IDataProxy<HomeIndexModel>.GetHandle(PageCacheType.HomeIndex).GetData();
            //长期兼职
            //var durable = new RecruitService(string.Empty).QueryRecruitment(0, 10, RecruitSheetType.Durable, RecruitSheetSubject.Default);
            ViewData["durable"] = proxydata.Durable;

            //最新兼职
            //var newjob = new RecruitService(string.Empty).QueryRecruitment(0, 40, RecruitSheetType.Normal, RecruitSheetSubject.Default);
            ViewData["newjob"] = proxydata.Newjob;

            //推荐兼职
            //var recommand = new RecruitService(string.Empty).QueryRecruitment(0, 40, RecruitSheetType.NoDefine, RecruitSheetSubject.Recommand);
            ViewData["Recommand"] = proxydata.Recommand;
            //var notice = SystemService.BaseNotice(5);
            //ViewData["notice"] = notice;
            return View();
        }
        #region 职位详情
        //[OutputCache(VaryByParam="id",Duration=60)]
        public ActionResult JobDetail()
        {
            var proxydata = IDataProxy<HomeJobDetailModel>.GetHandle(PageCacheType.HomeJobDetail).GetData(HttpContext.GetParameter("id").ToString());
            //var item = new RecruitService(string.Empty).GetRecruitment(id);
            ViewData["discussTime"] = proxydata.DiscussTimeForRecruitment;//new SystemService().QueryOfDiscussTimeForRecruitment(id);
            if (proxydata.Recruitment != null)//item != null)
            {
                ViewData["data"] = proxydata.Recruitment;
                return View();
            }
            return Redirect("/home/jobisempty");
        }
        public ActionResult JobIsEmpty()
        {
            return View();
        }
        public ActionResult MoreJob() 
        {
            string username = string.Empty;
            string ag = HttpContext.GetParameter("ag").Replace(' ','+');
            if (String.IsNullOrEmpty(ag))
            {
                return Redirect("/home/jobisempty");
            }
            try
            {
                username = EncodeByBase64.Decode(ag);
            }
            catch { return Redirect("/home/jobisempty"); }
            CorporationModel corp = new ueEngine.Biz.Core.AppService.Member.FirmService(username).GetCorporation(true);
            if (corp == null)
            {
                return Redirect("/home/jobisempty");
            }
            ViewData["Corp"] = corp;
            ItemListBox<PositionCell> positions = PositionSearchFromDB(
                RecruitSheetType.NoDefine,
                RecruitSheetSubject.Default,
                AreaCode.NoDefine,
                PositionType.NoDefine,
                username,
                0,
                15);
            ViewData["Positions"] = positions;

            ItemListBox<ShortDiscussModel> discusses = new ueEngine.Biz.Core.AppService.Support.SystemService().QueryOfDiscuss(0, 10, ReferenceCode.Agent, corp.AgentInfo.Id,-1);
            ViewData["Discusses"] = discusses;
            return View();
        }
        private static ItemListBox<PositionCell> PositionSearchFromDB(RecruitSheetType rt, RecruitSheetSubject subject, AreaCode areacode, PositionType pt, string agent, int page, int pageSize)
        {
            var qr = new RecruitService(string.Empty).QueryPosition(page, pageSize,
                rt, subject, areacode, pt, agent);
            var result = new ItemListBox<PositionCell>()
            {
                Data = new List<PositionCell>(),
                CurrentPage = qr.CurrentPage,
                ItemTotle = qr.ItemTotle,
                NextPage = qr.NextPage,
                PrePage = qr.PrePage,
                TotlePage = qr.TotlePage,
                PageItemSegment = qr.PageItemSegment
            };
            int itemCount = 0;
            foreach (var p in qr.Data)
            {
                result.Data.Add(new PositionCell()
                {
                    Abstract = p.RecruitSheet.Caption,
                    WorkAddress = p.RecruitSheet.WorkAddress,
                    WorkArea = p.RecruitSheet.WorkArea.Mapping(),
                    PositionDescript = p.PositionDescript,
                    PositionId = p.Id,
                    CertificationLevel = (int)p.CertificationLevel,
                    PositionName = p.PositionName,
                    PositionType = (int)p.PositionType,
                    Priority = (int)p.Priority,
                    PublishDate = p.RecruitSheet.Refresh,//p.RecruitSheet.PublishDate,
                    //RecuritDescript = p.RecruitSheet.Description,
                    RecuritId = p.RecruitSheet.Id,
                    Title = p.RecruitSheet.Caption,
                    Url = "/home/jobdetail_" + p.RecruitSheet.Id,
                    CompanyName = p.DepositCompany.CompanyName,
                    RecruitSheetSubject = (int)p.RecruitSheet.RecruitSubject
                });
                itemCount++;

            }
            //result = result.BuildPage(itemCount, page, pageSize);
            return result;
        }
        public ActionResult CorpDiscuss()
        {
            string username = string.Empty;
            string ag = HttpContext.GetParameter("ag").Replace(' ', '+');
            int apr = HttpContext.GetParameter("apr").ToInt32(-1);
            int page = HttpContext.GetParameter("page").ToInt32(0);
            if (String.IsNullOrEmpty(ag))
            {
                return Redirect("/home/jobisempty");
            }
            try
            {
                username = EncodeByBase64.Decode(ag);
            }
            catch { return Redirect("/home/jobisempty"); }
            CorporationModel corp = new FirmService(username).GetCorporation(true);
            if (corp == null)
            {
                return Redirect("/home/jobisempty");
            }
            ViewData["Corp"] = corp;
            ItemListBox<ShortDiscussModel> discusses = new SystemService().QueryOfDiscuss(page, 12, ReferenceCode.Agent, corp.AgentInfo.Id, apr);
            ViewData["Discusses"] = discusses;
            ViewData["ag"] = ag;
            string appraiseDetail = new SystemService().GetDiscussForAgentOfAppraiseDetail(username);
            ViewData["appraiseDetail"] = appraiseDetail;
            return View();
        }
        [ValidateInput(false)]
        [HttpPost]
        public ActionResult PostDiscuss()
        {
            string content = Server.HtmlEncode(HttpContext.GetParameter("content"));
            content = content.Replace("\r","").Replace("\n","<br/>");
            string agent = HttpContext.GetParameter("agent").Replace(' ', '+');
            int appraise = HttpContext.GetParameter("appraise").ToInt32(0);
            string rf = AesAlgorithm.Decrypt(agent);
            var user = new Biz.Core.AppService.Member.UserService(rf).GetUser();
            if (user == null)
            {
                return Redirect("/home/corpdiscuss_ag="+agent);
            }
            new ueEngine.Biz.Core.AppService.Support.SystemService()
            .PostDiscuss(new ShortDiscussModel() { 
                Appraise= (Appraise)appraise,
                Author=HttpContext.User.Identity.Name,
                Content=content,
                Down=0,
                ReferenceCode= ReferenceCode.Agent,
                ReferenceId = user.Id,
                Up=0,
                WriteDate=DateTime.Now,
                IsDelete = false
            });
            return Redirect("CorpDiscuss_ag=" + agent);
        }
        public ActionResult PostDiscussSucc()
        {
            return View();
        }
        [HttpPost]
        public int discussfeedback(int type, int id)
        {
            if (type == 1) //up
            {
                new ueEngine.Biz.Core.AppService.Support.SystemService().DiscussFeedback(id, true);
            }
            else if(type ==0) //down
            {
                new ueEngine.Biz.Core.AppService.Support.SystemService().DiscussFeedback(id, false);
            }
            return 0;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="p">职位id</param>
        /// <returns></returns>
        [Authorize]
        public ActionResult RequestJob(int p,int r)
        {
            if (new UserService(HttpContext.User.Identity.Name).GetUser().Role == MemberStatus.Firm)
            {
                return Redirect("/home/jobdetail_" + r);
            }
            var resume = new RecruitService(HttpContext.User.Identity.Name).QueryOfResumes(0, 8);
            ViewData["resumes"] = resume;
            if (!resume.Data.Any())
            {
                return Redirect("home/resumeisempty");
            }
            var position = new RecruitService(string.Empty).PositionDetail(p);
            ViewData["position"] = position;
            return View();
        }
        public ActionResult resumeisempty()
        {
            return View();
        }
        [Authorize]
        [HttpPost]
        public ActionResult RequestJob(int p, int r, int resume,string message,string title, int salarytype, int salary, int period)
        {
            message = message.Replace("\r\n", "<br/>");
            if (new RecruitService(HttpContext.User.Identity.Name).RequestJob(
                new RequestSheetModel() { 
                    Message = message,
                    Period = (SalaryPeriod)period,
                    SalaryType = (SalaryType)salarytype,
                    PositionId= p,
                    PostDate=DateTime.Now,
                    RecruitId=r,
                    ResumeId=resume,
                    Salary = salary,
                    UserName = HttpContext.User.Identity.Name,
                    Title =title
                }))
            {
                return Redirect("/home/sendresumesuc");
            }
            else
            {
                return Redirect("/home/sendresumefld");
            }
        }
        public ActionResult SendResumesuc()
        {
            return View();
        }
        public ActionResult SendResumefld()
        {
            return View();
        }
        public string feedback(string source, string message)
        {
            if (String.IsNullOrEmpty(message))
            {
                return "1";
            }
            message = message.Replace("\r", "").Replace("\n", "<br/>");
            if (new SystemService().PostFeedback(new FeedbackModel()
            {
                Admin = string.Empty,
                FeedbackType = FeedbackType.JobReport,
                IsProcess = false,
                Message = message,
                ReferenceUri = source,
                User = HttpContext.User.Identity.Name,
                WriteDate = DateTime.Now
            }))
            {
                return "1";
            }
            return "0";
        }
        public ActionResult RecruitmentDiscuss()
        {
            int id = HttpContext.GetParameter("id").ToInt32(0);
            int page = HttpContext.GetParameter("page").ToInt32(0);
            int apr = HttpContext.GetParameter("apr").ToInt32(-1);
            var item = new RecruitService(string.Empty).GetRecruitment(id);
            if (item != null)
            {
                ViewData["data"] = item; 
                var discuss = new SystemService().QueryOfDiscuss(page, 3, ReferenceCode.Recruitment, id, apr);
                ViewData["Discuss"] = discuss;
                string appraiseDetail = new SystemService().GetDiscussForRecruitmentOfAppraiseDetail(id);
                ViewData["appraiseDetail"] = appraiseDetail;
                ViewData["id"] = id;
                return View();
            }
            return Redirect("/home/jobisempty");
        }
        [ValidateInput(false)]
        [HttpPost]
        public ActionResult PostDiscussForRecuritment(int id, string content, int appraise)
        {
            content = Server.HtmlEncode(content);
            content = content.Replace("\r", "").Replace("\n", "<br/>");
            new ueEngine.Biz.Core.AppService.Support.SystemService()
            .PostDiscuss(new ShortDiscussModel()
            {
                Appraise = (Appraise)appraise,
                Author = HttpContext.User.Identity.Name,
                Content = content,
                Down = 0,
                ReferenceCode = ReferenceCode.Recruitment,
                ReferenceId = id,
                Up = 0,
                WriteDate = DateTime.Now,
                IsDelete = false
            });
            return Redirect("recruitmentdiscuss_" + id);
        }
        #endregion

        #region 职位搜索
        /// <summary>
        /// 搜索规则
        /// 
        /// a、最新招聘:
        ///     a.1、 (areaCode == -1 || 0 && positionType == -1 || 0) && qs == empty
        ///         读取数据库里的通过审核的职位，按照id（发布时间）倒序
        ///     a.2、 (areaCode == -1 || 0 && positionType == -1 || 0) && qs != empty
        ///         在全文搜索中，设定类型为最新招聘，按照qs进行模糊搜索
        ///     a.3、 not (areaCode ！= -1 || 0 && positionType ！= -1 || 0) && qs == empty
        ///         读取数据库里的通过审核的，符合地域，职位类型的职位，按照id（发布时间）倒序
        ///     a.4、 not (areaCode ！= -1 || 0 && positionType ！= -1 || 0) && qs != empty   
        ///         在全文搜索中 设定类型为最新招聘，设置地域，职位类型，发布时间在2周之内且未过期的职位为搜索范围。按照关键字命中率倒序
        /// b、长期招聘
        ///     b.1、 (areaCode == -1 || 0 && positionType == -1 || 0) && qs == empty
        ///         读取数据库里的通过审核的职位，按照id（发布时间）倒序
        ///     b.2、 (areaCode == -1 || 0 && positionType == -1 || 0) && qs != empty
        ///         设定类型为长期招聘，按照qs进行模糊搜索
        ///     b.3、 not (areaCode ！= -1 || 0 && positionType ！= -1 || 0) && qs == empty
        ///         读取数据库里的通过审核的，符合地域，职位类型的职位，按照id（发布时间）倒序
        ///     b.4、 not (areaCode ！= -1 || 0 && positionType ！= -1 || 0) && qs != empty   
        ///         在全文搜索中 设定类型为长期招聘， 设置地域，职位类型，发布时间在2周之内且未过期的职位为搜索范围。按照关键字命中率倒序
        /// </summary>
        /// <param name="areaCode"></param>
        /// <param name="positionType"></param>
        /// <param name="qs"></param>
        /// <param name="qt"></param>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <param name="agent">限定发帖用户</param>
        /// <returns></returns>
        [ValidateInput(false)]
        public ActionResult PositionList()
        {
            int areaCode =  this.HttpContext.GetParameter("areaCode").ToInt32(0);
            int positionType = this.HttpContext.GetParameter("positionType").ToInt32(0);
            string qs = this.HttpContext.GetParameter("qs");
            int qt = this.HttpContext.GetParameter("qt").ToInt32(0);
            int qj = this.HttpContext.GetParameter("qj").ToInt32(0);
            int page = this.HttpContext.GetParameter("page").ToInt32(0);
            int pageSize = this.HttpContext.GetParameter("pageSize").ToInt32(50);
            string ag = this.HttpContext.GetParameter("ag");

            qs = Server.HtmlEncode(qs);
            if (!String.IsNullOrEmpty(ag))
            {
                ag = EncodeByBase64.Decode(ag);
            }
            ItemListBox<PositionCell> result = new ItemListBox<PositionCell>();
            var cacheItem = IDataProxy<PositionListQueryModel>.GetHandle(PageCacheType.PositionListQuery).GetData(qs, 
                qt.ToString(), qj.ToString(), areaCode.ToString(), positionType.ToString(), ag, page.ToString(), pageSize.ToString());
            if (cacheItem != null)
            {
                result = cacheItem.result;
            }
            ViewData["data"] = result;
            return View();
        }

        #endregion

        #region 简历
#warning id需要缓存
        [Authorize]
        public ActionResult Resume()
        {
            try
            {
                int id = HttpContext.GetParameter("id").ToInt32(0);
                var resume = new RecruitService(HttpContext.User.Identity.Name).GetResume(id);
                ViewData["ResumeItem"] = resume;
            }
            catch (ContextException ex)
            {
                if (ex.ExceptionType == ExceptionType.OutOfDataBase)
                {
                    return Redirect("/home/resumenofound");
                }
                else
                {
                    throw ex;
                }
            }
            return View();
        }
        public ActionResult ResumeNoFound()
        {
            return View();
        }
        #endregion

        #region 搜藏职位
        /// <summary>
        /// 添加关注
        /// </summary>
        /// <param name="target">被关注的目标</param>
        /// <param name="at">被关注的类型</param>
        /// <returns></returns>
        [Authorize]
        public ActionResult Collect()
        {
            string target = HttpContext.GetParameter("target");
            AttentionType at = (AttentionType)HttpContext.GetParameter("at").ToInt32(1);
            if (at == AttentionType.Recruiter)
            {
                target = EncodeByBase64.Decode(target);
            }
            if (new SeekerService(HttpContext.User.Identity.Name).NewAttentionTarget(
                target, at) != null)
            {
                ViewData["ispass"] = 1;
            }
            else
            {
                ViewData["ispass"] = 0;
            }
            return View();
        }
        #endregion

        #region 关注人才
        [Authorize]
        public int NewTalent(int id)
        {
            var item =new RecruitService(HttpContext.User.Identity.Name).NewTalent(id);
            if (item != null)
            {
                return 1;
            }
            return 0;
        }
        [Authorize]
        public int DeleteTalent(int id)
        {
            return new RecruitService(HttpContext.User.Identity.Name)
                .RemoveTalent(id) ? 1 : 0;
        }
        #endregion

        #region 快速发布招聘
        public ActionResult RoleSelect()
        {
            return View();
        }
        public ActionResult NewPTJob() 
        {
            return View();
        }
        [ValidateInput(false)]
        [HttpPost]
        public ActionResult SpeedPublish(RecruitingVModel model, string UserName,string CorporationName,string CorpEmail,string Phone,string Location)
        {
            if (new UserService(UserName).CheckUserName() == 0)
            {
                if (new FirmService(UserName).Register(new MemberModel()
                {
                    CorporationInfo=new CorporationModel(){
                        CompanyName = CorporationName,
                        EMail = CorpEmail,
                        Phone = Phone,
                        Location = Location
                    },
                    Password = "111111",
                    Phone = Phone,
                    Location = Location
                }) != null)
                {
                    DepositCompanyModel depositCompany = new DepositCompanyModel()
                    {
                        Agent = UserName,
                        Id = model.DepositCompanyId,
                        CompanyBusiness = (Business)model.CompanyBusiness,
                        CompanyDetail = model.CompanyDetail,
                        CompanyDimensions = (CompanyDimensions)model.CompanyDimensions,
                        CompanyName = model.CompanyName,
                        CompanyType = (CompanyType)model.CompanyType,
                        PostDate = DateTime.Now,
                        Templete = model.CreateCompanyTemp == "on"
                    };

                    RecruitSheetModel recruitSheet = new RecruitSheetModel()
                    {
                        //Description = model.Description,
                        Caption = model.Caption,
                        RecruitType = model.RecruitType == "on" ? RecruitSheetType.Durable : RecruitSheetType.Normal,// RecruitSheetType.Normal,
                        PublishDate = DateTime.Now,
                        Recruiter = UserName,
                        RecruitSubject = RecruitSheetSubject.Default,                  
                        WorkArea = (AreaCode)model.WorkArea,
                        WorkAddress = model.WorkAddress,
                        Contact = model.ContactMan,
                        ContactPhone = model.ContactPhone,
                        Templete = model.CreateTempelte == "on",
                        DepositCompany = depositCompany,
                        Positions = CollectPosition(model.Position, Request.Form)
                            .Select(c => new PositionModel()
                            {
                                Degree = (Degree)c.Degree,
                                Experienced = c.Experienced == "on",
                                Gender = (Gender)c.Gender,
                                PositionDescript = c.PositionDescript,
                                PositionName = c.PositionName,
                                PositionType = (PositionType)c.PositionType,
                                IsIndex = false,
                                MaxSalary = c.MaxSalary,
                                MinSalary = c.MinSalary,
                                OperatorName = String.Empty,
                                Period = (SalaryPeriod)c.Period,
                                RecruitId = 0,
                                Trusteeship = false,
                                Vacancy = c.Vacancy,
                                ScanTime = 0,
                                Priority = (PositionPriority)(c.PositionPriority == "on" ? 1 : 0),
                                PositionLevel = PositionLevel.Normal
                            }).ToList()
                    };
                    List<PositionVModel> Positions = CollectPosition(model.Position, Request.Form);

                    if (new RecruitService(UserName).NewRecruit(recruitSheet) != null)
                    {
                        return Redirect("/home/publishSuccess_u=" + Server.UrlEncode(UserName));
                    }
                }
            }
            return Redirect("/home/publishFaild");
        }
        private List<PositionVModel> CollectPosition(int Position, NameValueCollection form)
        {
            List<PositionVModel> list = new List<PositionVModel>();
            for (int i = 0; i < Position; i++)
            {
                if (form["PositionName" + i] != null)
                {
                    list.Add(new PositionVModel()
                    {
                        MaxSalary = form["MaxSalary" + i].ToInt32(0),
                        MinSalary = form["MinSalary" + i].ToInt32(0),
                        Period = form["Period" + i].ToInt32(0),
                        PositionDescript = form["PositionDescript" + i],
                        PositionName = form["PositionName" + i],
                        Vacancy = form["Vacancy" + i].ToInt32(0),
                        Degree = form["Degree" + i].ToInt32(0),
                        Gender = form["Gender" + i].ToInt32(0),
                        Experienced = form["Experienced" + i],
                        PositionType = form["PositionType" + i].ToInt32(0),
                        PositionPriority = form["Priority"]
                    });
                }
            }
            return list;
        }
        public ActionResult PublishSuccess()
        {
            return View();
        }
        public ActionResult PublishFaild()
        {
            return View();
        }
        #endregion

        #region 企业级别
        public ActionResult CompanyLevel()
        {
            return View();
        }
        #endregion

        [OutputCache(Duration=3600,VaryByParam="none")]
        public ActionResult JoinUs()
        {
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Business()
        {
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Privacy()
        {
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Contact()
        {
            return View();
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult MessageBoard(string contact, string message) 
        {
            if (!String.IsNullOrEmpty(message.Trim()))
            {
                WorkPool.Append<AdvertisementEmail>(WorkType.email_for_advertisement,
                            new AdvertisementEmail()
                            {
                                DisplayName = "重庆大学生兼职网",
                                Title = "有人发来信息需要反馈",
                                Html = "<b>有一位用户发来反馈</b><p>联系方式：" + contact +
                                "</p><p>" + Server.HtmlEncode(message) + "</p><p>请尽快处理</p>",
                                Recipient = "support@yaojianzhi.com"
                            }, null);
            }
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult About()
        {
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Delegations()
        {
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Error()
        {  
            return View();
        }
        [OutputCache(Duration = 3600, VaryByParam = "none")]
        public ActionResult Groups()
        {
            return View();
        }
        public ActionResult NotFound() 
        {
            LogHelper.Write(CommonLogger.WebError, LogLevel.Error, "404 Not Found:" + Request.RawUrl);
            return View();
        }
        #region DataPump
        public string DoIndex()
        {
            LogHelper.Write(CommonLogger.System, LogLevel.Info, "ExchangeBiz.DoIndex()");
            ExchangeBiz.DoIndex();
            LogHelper.Write(CommonLogger.System, LogLevel.Info, "ExchangeBiz.DoAutoRefresh()");
            ExchangeBiz.DoAutoRefresh();
            return "success";
        }
        public ActionResult Pump() 
        {
            //new Thread(o =>
            //{
            //    LogHelper.Write(CommonLogger.System, LogLevel.Info, "Pump Is Start");
            //    try
            //    {
            //        DateTime start = GetLastDoTime();
            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, "Start Date:" + start.ToString());
            //        string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectStr"].ConnectionString;
            //        DataPump.IResource resource = new DataPump.ganjiResource(constr, start);
            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, "resource.Do (Begin)");
            //        resource.Do();
            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, "resource.Do (End)");
            //        OverWriteDoTime();

            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, "ExchangeBiz.DoIndex()");
            //        ExchangeBiz.DoIndex();
            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, "ExchangeBiz.DoAutoRefresh()");
            //        ExchangeBiz.DoAutoRefresh();
            //        string res = String.Format("共分析：{0}条数据{1}{2}条数据被记录{3}{4}因为数据异常被跳过{5}{6}因为非记录时间被跳过{7}{8}因为联系方式为空被跳过{9}{10}因为包含敏感文字被跳过{11}{12}因为重复被跳过",
            //            resource.total,
            //            Environment.NewLine, resource.recrod,
            //            Environment.NewLine, resource.jumpwitherror,
            //            Environment.NewLine, resource.jumpwithtime,
            //            Environment.NewLine, resource.jumpwithempty,
            //            Environment.NewLine, resource.jumpwithganji,
            //            Environment.NewLine, resource.repeat);
            //        LogHelper.Write(CommonLogger.System, LogLevel.Info, res);
            //    }
            //    catch (Exception e)
            //    {
            //        LogHelper.Write(CommonLogger.System, LogLevel.Error, e);
            //    }
            //}).Start();
            return View();
        }
        private DateTime OverWriteDoTime()
        {
            DateTime dt = DateTime.Now;
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "perpare.data", false))
            {
                sw.Write(dt.ToString());
                sw.Flush();
            }
            return dt;
        }
        private DateTime GetLastDoTime()
        {
            if (!System.IO.File.Exists(AppDomain.CurrentDomain.SetupInformation.ApplicationBase+"perpare.data"))
            {
                return DateTime.Now;
            }
            using (System.IO.StreamReader sr = new System.IO.StreamReader(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "perpare.data"))
            {
                try
                {
                    string str = sr.ReadLine();
                    DateTime dt = DateTime.Now;
                    if (DateTime.TryParse(str, out dt))
                    {
                        return dt;
                    }
                }
                catch { }
                return DateTime.Now;
            }
        }
        #endregion

        /// <summary>
        /// 富士康，英业达招聘是宣传页
        /// </summary>
        /// <returns></returns>
        public ActionResult Cooperation()
        {
            return View();
        }
        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Cooperation(string Name, int Gender, int Age, string IdNo, string Phone, string Job, string remark)
        {
            NewBizService.SaveNewApplicationForm(new ApplicationFormModel() { 
                Age= Age,
                Gender= Gender == 1? ueEngine.Biz.Inf.LogicEntity.Gender.Male: Biz.Inf.LogicEntity.Gender.Female,
                IdNo=IdNo,
                Job=Job,
                Name=Name,
                Remark=remark,
                Phone=Phone
            });
            return RedirectToAction("ApplicationSuc");
        }

        public ActionResult ApplicationSuc()
        {
            return View();
        }

        public ActionResult pugong()
        {
            return View();
        }

        public ActionResult jxjy()
        {
            return View();
        }

        public ActionResult ticket()
        {
            return View();
        }
    }
}
